
//
//  ALHomeTileButton.swift
//  Swift01
//
//  Created by Miaoyang on 16/4/13.
//  Copyright © 2016年 Miaoyang. All rights reserved.
//

import UIKit

class ALHomeTileButton: UIButton {
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //使用构造函数,子类实现了后就不会去继承父类的
    init(title:String){
        
        super.init(frame: CGRectZero)
        self.setTitle(title, forState: UIControlState.Normal)
        self.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        self.setImage(UIImage(named: "navigationbar_arrow_down"), forState: UIControlState.Normal)
        self.sizeToFit()
        
    }
    
    //该表frame,需要拿到layout
    override func layoutSubviews() {
        super.layoutSubviews()
        
        //重新设置按钮的图片的文字的位置
        titleLabel?.frame.origin.x = 0
        //将图片设置到文字的右边
        imageView?.frame.origin.x = titleLabel!.frame.width + 3
    }

}
